//
//  MQBaseUserInfoModel.m
//  meiquan
//
//  Created by hejingjin on 2017/10/30.
//  Copyright © 2017年 mq. All rights reserved.
//

#import "MQBaseUserInfoModel.h"

#define AgentIds @"agentIds"
#define IsAgent @"isAgent"
#define Token @"token"
#define UserId @"userId"
#define UserNormalId @"userNormalId"
#define Username @"username"
#define Weixin @"weixin"



static MQBaseUserInfoModel *userinfo = nil;

@implementation MQBaseUserInfoModel



+(instancetype)shareInstant{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        userinfo = [[MQBaseUserInfoModel alloc] init];
    });
    return userinfo;
    
}

-(void)loadUserinfoFromSadeBox{
    
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];

    
    self.userId = [userDefaults objectForKey:UserId];
    self.isAgent = [userDefaults boolForKey:IsAgent];
    self.token = [userDefaults objectForKey:Token];
    self.agentIds = [userDefaults objectForKey:AgentIds];
    self.userNormalId = [userDefaults objectForKey:UserNormalId];
    self.username = [userDefaults objectForKey:Username];
    self.weixin = [userDefaults objectForKey:Weixin];
    self.birthday = [userDefaults objectForKey:@"birthday"];
    self.gender = [userDefaults objectForKey:@"gender"];
    self.area = [userDefaults objectForKey:@"area"];
    self.deviceToken = [userDefaults objectForKey:@"deviceToken"];
    
}

-(void)saveUserInfoToSadeBox{
    
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    [userDefaults setObject:self.username forKey:Username];
    [userDefaults setObject:self.userId forKey:UserId];
    [userDefaults setObject:self.token forKey:Token];
    [userDefaults setObject:self.agentIds forKey:AgentIds];
    [userDefaults setObject:self.weixin forKey:Weixin];
    [userDefaults setObject:self.userNormalId forKey:UserNormalId];
    [userDefaults setBool:self.isAgent forKey:IsAgent];
    [userDefaults setObject:self.birthday forKey:@"birthday"];
    [userDefaults setObject:self.gender forKey:@"gender"];
    [userDefaults setObject:self.area forKey:@"area"];
    [userDefaults setObject:self.deviceToken forKey:@"deviceToken"];
    [userDefaults synchronize];
}
-(void)cleancurrentUserinfo{
    
}

@end
